/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmAsigarSeccion.java
 *
 * Created on 16/02/2011, 04:11:50 PM
 */
package Principal;

import Clases.Seccion;
import java.awt.Frame;
import javax.swing.JOptionPane;

public class frmAsigarSeccion extends javax.swing.JFrame {

	/** Creates new form frmAsigarSeccion */
	public frmAsigarSeccion() {

		initComponents();

	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed"
	// desc="Generated Code">//GEN-BEGIN:initComponents
	private void initComponents() {

		jLabel1 = new javax.swing.JLabel();
		txtNumSec = new javax.swing.JTextField();
		bAceptar = new javax.swing.JButton();

		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		setAlwaysOnTop(true);
		setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
		getContentPane().setLayout(null);

		jLabel1.setText("Ingrese Numero de Seccion");
		getContentPane().add(jLabel1);
		jLabel1.setBounds(100, 30, 180, 40);

		txtNumSec.setHorizontalAlignment(javax.swing.JTextField.CENTER);
		txtNumSec.addKeyListener(new java.awt.event.KeyAdapter() {
			public void keyPressed(java.awt.event.KeyEvent evt) {
				txtNumSecKeyPressed(evt);
			}

			public void keyReleased(java.awt.event.KeyEvent evt) {
				txtNumSecKeyReleased(evt);
			}

			public void keyTyped(java.awt.event.KeyEvent evt) {
				txtNumSecKeyTyped(evt);
			}
		});
		getContentPane().add(txtNumSec);
		txtNumSec.setBounds(110, 80, 120, 40);

		bAceptar.setText("Aceptar");
		bAceptar.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				bAceptarActionPerformed(evt);
			}
		});
		getContentPane().add(bAceptar);
		bAceptar.setBounds(120, 140, 100, 30);

		java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit()
				.getScreenSize();
		setBounds((screenSize.width - 361) / 2, (screenSize.height - 281) / 2,
				361, 281);
	}// </editor-fold>//GEN-END:initComponents

	private void bAceptarActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_bAceptarActionPerformed
		// TODO add your handling code here:
		if (txtNumSec.getText().equals("")) {
			JOptionPane.showMessageDialog(new Frame(),
					"Ingrese Numero de Sección");
		} else {
			frmInicial.seccion.setNumeroSeccion(txtNumSec.getName());

			JOptionPane.showMessageDialog(new Frame(), "Seccion Creada");
			dispose();

		}

	}// GEN-LAST:event_bAceptarActionPerformed

	private void txtNumSecKeyPressed(java.awt.event.KeyEvent evt) {// GEN-FIRST:event_txtNumSecKeyPressed
	}// GEN-LAST:event_txtNumSecKeyPressed

	private void txtNumSecKeyTyped(java.awt.event.KeyEvent evt) {// GEN-FIRST:event_txtNumSecKeyTyped
		// TODO add your handling code here:
	}// GEN-LAST:event_txtNumSecKeyTyped

	private void txtNumSecKeyReleased(java.awt.event.KeyEvent evt) {// GEN-FIRST:event_txtNumSecKeyReleased
		// TODO add your handling code here:
		char c;
		c = evt.getKeyChar();
		if (!(c < '0' || c > '9')) {
			evt.consume();// ignora el caracter digitado
		} else {
			JOptionPane.showMessageDialog(new Frame(), "Solo numeros", "Error",
					JOptionPane.INFORMATION_MESSAGE);
		}
	}// GEN-LAST:event_txtNumSecKeyReleased

	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {

			public void run() {
				new frmAsigarSeccion().setVisible(true);
			}
		});
	}

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JButton bAceptar;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JTextField txtNumSec;
	// End of variables declaration//GEN-END:variables
}
